<?php
	include_once "dataservice.php";
	
	class danhmuc_db
	{
		public function Them($MaDanhMuc = "", $TenDanhMuc = "")
		{
			$sql = "INSERT INTO tbl_loaisach(MaDanhMuc, TenDanhMuc)
					VALUES($MaDanhMuc, '$TenDanhMuc')";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		
		public function CapNhat($MaDanhMuc = "", $TenDanhMuc = "")
		{
			$sql = "UPDATE tbl_loaisach SET TenDanhMuc = '$TenDanhMuc' WHERE MaDanhMuc = $MaDanhMuc";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		
		public function Xoa($MaDanhMuc = "")
		{
			$sql = "DELETE FROM tbl_loaisach WHERE MaDanhMuc = $MaDanhMuc";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		
		public function LayDanhSach($MaDanhMuc = "")
		{
			$sql = "SELECT * FROM tbl_loaisach WHERE 1";
			
			if($MaDanhMuc != "")
				$sql .= " AND MaDanhMuc = $MaDanhMuc";
			
			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}
	}
?>